import csv, os, sys

path = sys.argv[1]
output_dir = os.path.join(os.path.dirname(path), 'translate_output')
os.makedirs(output_dir, exist_ok=True)
translate_data = [
	["记录仪型号","记录仪型号(Recorder model)"],
	["记录仪编号","记录仪编号(Recorder serial number)"],
	["记录仪运行状态:  运行", "记录仪运行状态(Recorder running state):  运行(Running)"],
	["信息备份功能", "信息备份功能(Backup function)"],
	["报警", "报警(Alarm)"],
	["记录间隔:  记录时间间隔 30 秒", "记录间隔(Record interval):  记录时间间隔 30 秒(10 second)"],
	["任务开始时间","任务开始时间(Task start time)"], 
	["记录数据量（条）", "记录数据量（条）(Recoed data count)"],
	["是否滚动覆盖", "是否滚动覆盖(scroll over)"],
	["第一条数据开始时间", '第一条数据开始时间(First data start time)'],
	["记录总数", "记录总数(Record total count)"],
	["记录数据累计", "记录数据累计(Accumulate recorded data)"],
	["温度分辨率", "温度分辨率(temperature resolution)"],
	["高温报警:  未设置", "高温报警(High temperature alarm):  未设置(Not set)"],
	["低温报警:  未设置", "低温报警(Low temperature alarm):  未设置(Not set)"],
	["湿度分辨率:  0.6 %RH", "湿度分辨率(Humidity resolution):  0.6 %RH,"],
	["高湿报警:  未设置", "高湿报警(High humidity alarm):  未设置(Not set)"],
	["低湿报警:  未设置", "低湿报警(High humidity alarm):  未设置(Not set)"],
]

with open (path, 'r', encoding='gbk') as f:
	csv_obj = csv.reader(f)
	ret = []
	for i, line in enumerate(csv_obj):
		if i<len(translate_data):
			line[0] = line[0].replace(translate_data[i][0], translate_data[i][1])
		ret.append(line)
	# print(ret)
	f = open(os.path.join(output_dir, os.path.basename(path)), 'w', encoding='gbk', newline='')
	csv_obj = csv.writer(f)
	csv_obj.writerows(ret)
